﻿#include "LoginWindow.h"
#include "ui_LoginWindow.h"
#include <QMessageBox>
#include "PublicData.h"

LoginWindow::LoginWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::LoginWindow)
{
    ui->setupUi(this);
    m_LicenseCodeMGT = new LicenseCodeManagement();
}

LoginWindow::~LoginWindow()
{
    delete ui;
}

//登录
void LoginWindow::on_pbLogin_clicked()
{
    //进行授权验证，如果验证未通过就打开授权界面，反之则获取授权机型id，并打开主界面
    if(m_LicenseCodeMGT->getResultCode() == SUCCESS){  //授权成功，获取机型id，打开主界面
        PublicData::setPlaneTypeID(m_LicenseCodeMGT->getPlaneTypeID());  //将获取到的机型id设置为公共信息
        emit openICDSingal();
    }
    else{
        QMessageBox::information(this,"登录提示","授权失败，请重新授权");
        emit openLicenseSingal(m_LicenseCodeMGT);
    }
}

//退出
void LoginWindow::on_pbExit_clicked()
{
    this->close();
}
